package com.hrm.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.hrm.entity.StaffLeave;
import com.hrm.entity.StaffRoom;
import com.hrm.vo.StaffLeaveVO;
import com.hrm.vo.StaffRoomVO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * <p>
 * Mapper 接口
 * </p>
 *
 * @author qiujie
 * @since 2022-04-05
 */
public interface StaffRoomMapper extends BaseMapper<StaffRoom> {


    @Select("select asr.*,atr.room_name from att_staff_room asr " +
            "inner join att_room atr on atr.id = asr.room_id " +
            "where asr.is_deleted = 0 and asr.staff_id = #{id}")
    IPage<StaffRoomVO> listStaffRoomVOByStaffId(IPage<StaffRoomVO> config, @Param("id") Integer id);

    /**
     * 不显示撤销的请假申请
     *
     * @param config
     * @param name
     * @return
     */
    @Select("select asr.*,ss.name,ss.code,ss.phone,atr.room_name from att_staff_room asr " +
            "inner join sys_staff ss on ss.id = asr.staff_id " +
            "inner join att_room atr on atr.id = asr.room_id " +
            "where asr.is_deleted = 0 and asr.status != 3 and ss.name like concat('%',#{name},'%')")
    IPage<StaffRoomVO> listStaffRoomVO(IPage<StaffRoomVO> config, @Param("name") String name);

    @Select("select asr.*,atr.room_name from att_staff_room asr " +
            "inner join att_room atr on atr.id = asr.room_id " +
            "inner join sys_dept sd on sd.id = asr.dept_id " +
            "where asr.is_deleted = 0 and asr.status = 1 and asr.dept_id = #{id}")
    IPage<StaffRoomVO> listStaffRoomVOByDeptId(IPage<StaffRoomVO> config, @Param("id") Integer id);

    /**
     * 只显示审批成功之后申请
     *
     * @param config
     * @param name
     * @return
     */
    @Select("select asr.*,ss.name,ss.code,ss.phone,atr.room_name from att_staff_room asr " +
            "inner join sys_staff ss on ss.id = asr.staff_id " +
            "inner join att_room atr on atr.id = asr.room_id " +
            "where asr.is_deleted = 0 and asr.status = 1 and ss.name like concat('%',#{name},'%')")
    IPage<StaffRoomVO> listStaffRoomVOByStatus(IPage<StaffRoomVO> config, @Param("name") String name);

//    IPage<StaffRoomVO> listByStatus(IPage<StaffRoomVO> config, String name);
}
